/*    */ package com.zimbra.cs.gal;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DistributionListBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.ExternalGroup;
/*    */ import com.zimbra.cs.account.grouphandler.GroupHandler;
/*    */ import com.zimbra.cs.ldap.IAttributes;
/*    */ import com.zimbra.cs.ldap.IAttributes.CheckBinary;
/*    */ import com.zimbra.cs.ldap.ILdapContext;
/*    */ import java.util.Arrays;
/*    */ import java.util.List;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ZimbraGalGroupHandler
/*    */   extends GroupHandler
/*    */ {
/*    */   public boolean isGroup(IAttributes ldapAttrs)
/*    */   {
/*    */     try
/*    */     {
/* 42 */       List<String> objectclass = ldapAttrs.getMultiAttrStringAsList("objectClass", IAttributes.CheckBinary.NOCHECK);
/*    */       
/* 44 */       return (objectclass.contains(AttributeClass.OC_zimbraDistributionList)) || (objectclass.contains(AttributeClass.OC_zimbraGroup));
/*    */     }
/*    */     catch (ServiceException e) {
/* 47 */       ZimbraLog.gal.warn("unable to get attribute objectClass", e);
/*    */     }
/* 49 */     return false;
/*    */   }
/*    */   
/*    */   public String[] getMembers(ILdapContext ldapContext, String searchBase, String entryDN, IAttributes ldapAttrs)
/*    */     throws ServiceException
/*    */   {
/* 55 */     ZimbraLog.gal.debug("Fetching members for group " + ldapAttrs.getAttrString("mail"));
/* 56 */     List<String> objectclass = ldapAttrs.getMultiAttrStringAsList("objectClass", IAttributes.CheckBinary.NOCHECK);
/*    */     
/*    */ 
/* 59 */     String[] members = null;
/* 60 */     if (objectclass.contains(AttributeClass.OC_zimbraDistributionList)) {
/* 61 */       members = ldapAttrs.getMultiAttrString("zimbraMailForwardingAddress");
/* 62 */     } else if (objectclass.contains(AttributeClass.OC_zimbraGroup)) {
/* 63 */       String zimbraId = ldapAttrs.getAttrString("zimbraId");
/* 64 */       Provisioning prov = Provisioning.getInstance();
/* 65 */       Group group = prov.getGroupBasic(Key.DistributionListBy.id, zimbraId);
/* 66 */       if (group == null) {
/* 67 */         throw AccountServiceException.NO_SUCH_GROUP(zimbraId);
/*    */       }
/* 69 */       members = prov.getGroupMembers(group);
/*    */     }
/*    */     
/* 72 */     Arrays.sort(members);
/* 73 */     return members;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean inDelegatedAdminGroup(ExternalGroup group, Account acct, boolean asAdmin)
/*    */     throws ServiceException
/*    */   {
/* 82 */     throw ServiceException.FAILURE("internal error", null);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/gal/ZimbraGalGroupHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */